package Server.Poker.ZJH;

import java.math.BigDecimal;
import java.util.Arrays;

import org.json.JSONObject;



class IJsonExport {

	String getJsonData() {
		return null;
	}

	public String sprintf_BYTE(int by[][], int count) {

		int tmpCardData[] = new int[count]; // 用户扑克
		for (int i = 0; i < by.length; i++) {
			for (int k = 0; k < by[i].length; k++) {
				tmpCardData[i * by.length + k] = by[i][k];
			}
		}
		String strCardData = sprintf_BYTE(tmpCardData, count);
		return strCardData;
	}
	
	public String sprintf_BYTE(int by[], int count) {
		return sprintf_INT32(by, count);
	}
	public String sprintf_DWORD(int dw[], int count) {
		return sprintf_INT32(dw, count);
	}
	public String sprintf_INT32(int dw[], int count) {
		if (count < 1) {
			return "";
		}
		StringBuffer out_str = new StringBuffer();
		out_str.append(dw[0]);
		for (int i = 1; i < count; i++) {
			out_str.append(",");
			out_str.append(dw[i]);
		}
		return out_str.toString();
	}

	public String sprintf_Double(double by[][],int count){
		double tmpCardData[] = new double[count]; // 用户扑克
		for (int i = 0; i < by.length; i++) {
			for (int k = 0; k < by[i].length; k++) {
				tmpCardData[i * by.length + k] = by[i][k];
			}
		}
		String strCardData = sprintf_Double(tmpCardData, count);
		return strCardData;
	}
	public String sprintf_Double(double by[], int count) {
		return sprintf_DOUBLE(by, count);
	}
	public String sprintf_DOUBLE(double dw[], int count) {
		if (count < 1) {
			return "";
		}
		StringBuffer out_str = new StringBuffer();
		out_str.append(big2(dw[0]));
		for (int i = 1; i < count; i++) {
			out_str.append(",");
			out_str.append(big2(dw[i]));
		}
		return out_str.toString();
	}
	private static String big2(double d) {
		BigDecimal d1 = new BigDecimal(Double.toString(d)); 
		BigDecimal d2 = new BigDecimal(Integer.toString(1));
		return d1.divide(d2,2,BigDecimal.ROUND_HALF_UP).toString();
	}
};

/***
 * 玩家请求进入房间
 */
class SUBCMD_S_Connect extends IJsonExport {

	int m_lUid;

	String getJsonData() {
		String zjhmsg = String.format("connect|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Join extends IJsonExport {

	int m_lUid;

	String getJsonData() {

		String zjhmsg = String.format("join|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 离开房间通知
class SUBCMD_S_Leave extends IJsonExport {

	int m_lUid;// 玩家ID

	String getJsonData() {

		String zjhmsg = String.format("leave|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 离开房间通知
class SUBCMD_S_Offline extends IJsonExport {

	int m_lUid;// 玩家ID

	String getJsonData() {

		String zjhmsg = String.format("offline|%d", m_lUid);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_CreateRoom extends IJsonExport {

	int cbResult;
	int cbRound;
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("createroom|%d|%d|%d|%d", cbResult, cbRound, m_wUserChairID, m_dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Param extends IJsonExport {

	int m_dwTableID;// 房间ID
	String szParam;
	String szRoomDesc;	
	int m_ldifen;
	int m_creater;
	double dwcKouYingRate;
	int m_kouYingJuShu;
	String getJsonData() {

		//String zjhmsg = String.format("param|%d|%s|%s|%d|%d|%d", m_dwTableID, szParam,szRoomDesc,m_ldifen,m_daikai,m_creater);
		String zjhmsg = String.format("param|%d|%s|%d|%d|%s|%g|%d", m_dwTableID, szParam,m_ldifen,m_creater,szRoomDesc,dwcKouYingRate,m_kouYingJuShu);
		
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_TryDismissRoom extends IJsonExport {

	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String zjhmsg = String.format("try_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_AgreeDismissRoom extends IJsonExport {

	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String zjhmsg = String.format("agree_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_RefuseDismissRoom extends IJsonExport {

	int lUid;
	String szNickName;//
	int dwTableID;// 房间ID

	String getJsonData() {
		String zjhmsg = String.format("refuse_dismissroom|%d|%s|%d", lUid, szNickName, dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_DismissRoom extends IJsonExport {

	int cbResult;
	int lUid;
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("dismissroom|%d|%d|%d|%d", cbResult, lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_JoinRoom extends IJsonExport {

	int lUid;
	int cbResult;
	int dwTableID;// 房间ID
	int cbRound;

	String strParam;
	String szGameDesc;

	String getJsonData() {

		String zjhmsg = String.format("joinroom|%d|%d|%d|%d|%s|%s", lUid, cbResult, dwTableID, cbRound, strParam,
				szGameDesc);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_AvatarURL extends IJsonExport {

	int lUid;
	String szURL;

	String getJsonData() {

		String zjhmsg = String.format("avatar|%d|%s", lUid, szURL);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Sit extends IJsonExport {

	int m_lUid;
	int m_wChairID;// 座位ID
	int m_dwTableID;// 房间ID
	int m_lUserScore;
	String szNickName;
	int m_cbGender;
	int m_lBetCoin;
	String szIP;
	int m_cbUserStatus;
	int m_lUserCoin;
	double m_lUserRmb;

	String getJsonData() {

		String zjhmsg = String.format("sit|%d|%d|%d|%d|%s|%d|%d|%s|%d|%d|%g", m_lUid, m_wChairID, m_dwTableID,
				m_lUserScore, szNickName, m_cbGender, m_lBetCoin, szIP,m_cbUserStatus,m_lUserCoin,m_lUserRmb);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_DenySit extends IJsonExport {

	int cbReason; // 1,没有找到房间,2，房间已满

	String getJsonData() {

		String zjhmsg = String.format("denysit|%d", cbReason);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Look extends IJsonExport {

	int m_lUid;
	int m_wUserChairID;// 房间ID
	int m_iTotalCoin;
	String szNickName;

	String getJsonData() {

		String zjhmsg = String.format("look|%d|%d|%d|%d|%s", m_lUid, m_wUserChairID, m_iTotalCoin, szNickName);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_StandUp extends IJsonExport {

	int m_lUid;// 玩家ID
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID
	int leaveRoom;
	String getJsonData() {

		String zjhmsg = String.format("standup|%d|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID,leaveRoom);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Kick extends IJsonExport {

	int m_lUid;// 玩家ID
	int m_wUserChairID;// 座位ID
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("kick|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Ready extends IJsonExport {
	int m_lUid;// 玩家ID
	int m_wUserChairID;// 玩家座位
	int m_dwTableID;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("ready|%d|%d|%d", m_lUid, m_wUserChairID, m_dwTableID);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

/***
 * 房间信息
 */
class SUBCMD_S_CardStatus extends IJsonExport {// 同步房间玩家信息
	int m_cbCardStatus[] = new int[5];

	String getJsonData() {
		String card_status = Arrays.toString(m_cbCardStatus);
		card_status = card_status.substring(1, card_status.length() - 1);

		String zjhmsg = String.format("card_status|%s", card_status);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

/***
 * 房间信息
 */
class SUBCMD_S_StatusFree extends IJsonExport {// 同步房间玩家信息

	int m_lCellScore;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("status_free|%d", m_lCellScore);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_UserScore extends IJsonExport {// 同步房间玩家分数

	int m_lUid;// 房间ID
	int m_lUserScore;// 房间ID
	int m_lUserGem;// 房间ID
	int m_iVipLevel;// 房间ID

	String getJsonData() {

		String zjhmsg = String.format("userscore|%d|%d|%d|%d", m_lUid, m_lUserScore, m_lUserGem, m_iVipLevel);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 同步房间玩家信息
class SUBCMD_S_StatusPlay extends IJsonExport {
	int m_lCellScore;// 房间ID
	int m_cntTableChip[] = new int[5];// 1x,3x,5x,8x,10x
	int m_cbCardStatus[] = new int[5];
	int m_AllBetCoin[] = new int[5];// 底注
	int m_AllUserCoin[] = new int[5];// 每个玩家多少钱

	String getJsonData() {
		String strTableChip = Arrays.toString(m_cntTableChip);
		strTableChip = strTableChip.substring(1, strTableChip.length() - 1);

		String strCardStatus = Arrays.toString(m_cbCardStatus);
		strCardStatus = strCardStatus.substring(1, strCardStatus.length() - 1);

		String strBetCoin = Arrays.toString(m_AllBetCoin);
		strBetCoin = strBetCoin.substring(1, strBetCoin.length() - 1);

		String strUserCoin = Arrays.toString(m_AllUserCoin);
		strUserCoin = strUserCoin.substring(1, strUserCoin.length() - 1);

		String zjhmsg = String.format("status_play|%d|%s|%s|%s|%s", m_lCellScore, strTableChip, strCardStatus,
				strBetCoin, strUserCoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_User extends IJsonExport {

	int m_lUid;// UID
	int m_wUserChairID;// 座位号ID
	int m_bIsLookOn;// 是否是观众
	int m_iCoin;// COIN
	String m_NickName;// NICKNAME
	int m_iVipLevel;// VIP LEVEL
	int m_iSex;// VIP LEVEL

	String getJsonData() {

		String zjhmsg = String.format("user|%d|%d|%d|%s|%d|%d|%d", m_lUid, m_wUserChairID, m_bIsLookOn, m_iCoin,
				m_NickName, m_iVipLevel, m_iSex);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_AwardTime extends IJsonExport {
	int lUid;
	int lAwardLevel;// 1-10分钟，分别领取 100-1000金币
	int lAwardCoin;
	int lRemainTime;
	int lGetCoin;

	String getJsonData() {
		String zjhmsg = String.format("awardtime|%d|%d|%d|%d|%d", lUid, lAwardLevel, lAwardCoin, lRemainTime,
				lGetCoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Alms extends IJsonExport {
	int lUid;
	int lAlmsCoin;
	int lTotalCoin;

	String getJsonData() {
		String zjhmsg = String.format("alms|%d|%d|%d", lUid, lAlmsCoin, lTotalCoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 聊天表情
class SUBCMD_S_BiaoQing extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位
	int m_iBiaoQingIndex;

	String getJsonData() {

		String zjhmsg = String.format("biaoqing|%d|%d|%d", m_lUid, m_wUserChairID, m_iBiaoQingIndex);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_YuYin extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	int m_iYuYinIndex;

	String getJsonData() {

		String zjhmsg = String.format("yuyin|%d|%d|%d", m_lUid, m_wUserChairID, m_iYuYinIndex);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 送礼
class SUBCMD_S_SongLi extends IJsonExport {
	int m_srcUid;// 哪个玩家ID获得
	int m_dstUid;// 玩家座位 号
	int m_iLiWu;
	int m_srcCoin;// 送礼的人余下多少钱
	int m_dstCoin;// 收礼的人余下多少钱

	String getJsonData() {

		String zjhmsg = String.format("use|%d|%d|%d|%d|%d", m_srcUid, m_dstUid, m_iLiWu, m_srcCoin, m_dstCoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_FaPai extends IJsonExport {
	int byRound; // 最大下注
	int vecIsReady[] = new int[5]; // 游戏得分
	int wCurrentUser; // 当前玩家
	int lTurnMaxGold; // 最大下注
	int lTurnMinGold; // 最少下注
	int m_lCellScore; // 最少下注

	String getJsonData() {

		String strDstChairID = Arrays.toString(vecIsReady);
		strDstChairID = strDstChairID.substring(1, strDstChairID.length() - 1);

		String zjhmsg = String.format("fapai|%d|%s|%d|%d|%d|%d", byRound, strDstChairID, wCurrentUser, lTurnMaxGold,
				lTurnMinGold,m_lCellScore);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 用户放弃
class SUBCMD_S_FangQi extends IJsonExport {
	int m_lUid;// 玩家ID
	int m_wUserChairID; // 放弃用户

	String getJsonData() {

		String zjhmsg = String.format("fangqi|%d|%d", m_lUid, m_wUserChairID);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_GenZhu extends IJsonExport {

	int m_lUid; // 当前玩家
	int m_wUserChairID; // 玩家座位号
	int m_lGold; // 下注金币
	int m_bKanPai; // 是否看牌
	int wLastChairID; // 上一用户
	int wCurrentUser; // 当前用户
	int m_allTableGold;//桌子总金币
	int m_curUserdifen;//当前玩家的押注总金币

	String getJsonData() {

		String zjhmsg = String.format("genzhu|%d|%d|%d|%d|%d|%d|%d|%d", m_lUid, m_wUserChairID, m_lGold, m_bKanPai,
				wLastChairID, wCurrentUser,m_allTableGold,m_curUserdifen);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_JiaZhu extends IJsonExport {
	int m_lUid; // 当前玩家
	int m_wUserChairID; // 玩家座位号
	int m_lGold; // 下注金币
	int m_bKanPai; // 是否看牌
	int wLastChairID; // 上一用户
	int wCurrentUser; // 当前用户
	int m_allTableGold;
	int m_curUserdifen;

	String getJsonData() {

		String zjhmsg = String.format("jiazhu|%d|%d|%d|%d|%d|%d|%d|%d", m_lUid, m_wUserChairID, m_lGold, m_bKanPai,
				wLastChairID, wCurrentUser,m_allTableGold,m_curUserdifen);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_KanPai extends IJsonExport {
	int m_lUid; // 当前玩家
	int m_wUserChairID;// 玩家座位号
	int wCurrentUser; // 当前用户
	int bCardData[] = new int[3]; // 用户扑克

	String getJsonData() {
		String strCardData = Arrays.toString(bCardData);
		strCardData = strCardData.substring(1, strCardData.length() - 1);

		String zjhmsg = String.format("kanpai|%d|%d|%d|%s", m_lUid, m_wUserChairID, wCurrentUser, strCardData);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_BiPai extends IJsonExport {
	int m_srcUid; // 当前玩家
	int m_dstUid; // 当前玩家
	int m_loseUid; // 赢的用户
	int m_srcSeat;// 玩家座位号
	int m_dstSeat;// 玩家座位号
	int m_loseSeat; // 赢的座位号
	int wCurrentUser; // 当前用户

	String getJsonData() {

		String zjhmsg = String.format("bipai|%d|%d|%d|%d|%d|%d|%d", m_srcUid, m_srcUid, m_loseUid, m_srcSeat,
				m_dstSeat, m_loseSeat, wCurrentUser);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_KaiPai extends IJsonExport {
	int m_srcUid; // 当前玩家
	int m_dstUid; // 目标玩家
	int m_winnerUid; // 赢的用户
	int m_srcSeat; // 玩家座位号
	int m_dstSeat; // 玩家座位号
	int m_winnerSeat; // 赢的座位号
	int srcCardData[] = new int[3]; // 用户扑克
	int dstCardData[] = new int[3]; // 用户扑克

	String getJsonData() {

		String strSrcCardData = Arrays.toString(srcCardData);
		strSrcCardData = strSrcCardData.substring(1, strSrcCardData.length() - 1);

		String strDstCardData = Arrays.toString(dstCardData);
		strDstCardData = strDstCardData.substring(1, strDstCardData.length() - 1);

		String zjhmsg = String.format("kaipai|%d|%d|%d|%d|%d|%d|%s|%s", m_srcUid, m_dstUid, m_winnerUid, m_srcSeat,
				m_dstSeat, m_winnerSeat, strSrcCardData, strDstCardData);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Avatar extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	String szAvatarURL;

	String getJsonData() {

		String zjhmsg = String.format("avatar|%d|%s", m_lUid, szAvatarURL);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Chat extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	String szContent;

	String getJsonData() {

		String zjhmsg = String.format("chat|%d|%d|%s", m_lUid, m_wUserChairID, szContent);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 语音
class SUBCMD_S_Voice extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	int seconds;
	String szVoiceURL;

	String getJsonData() {

		String zjhmsg = String.format("voice|%d|%d|%d|%s", m_lUid, m_wUserChairID, seconds, szVoiceURL);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SSeatInfo {
	int m_lUid;// UID
	int m_lTotalScore;// COIN
	String m_NickName;// NICKNAME
	int m_lBetCoin;//
	int m_cbGender;//
	int m_iAvatar;//
	int m_cbUserStatus;// 用户状态
	int m_iVipLevel;// VIP LEVEL
	int m_iTitle;// 称号
	int m_isLookon;// 是否观众
	String szIP;
	int m_iTotalCoin;
	double m_iTotalRmb;
	
	public String toString() {

		String zjhmsg = String.format("%d#%d#%s#%d#%d#%d#%d#%d#%d#%d#%s#%d#%g", m_lUid, m_lTotalScore, m_NickName, m_lBetCoin,
				m_cbGender, m_iAvatar, m_cbUserStatus, m_iVipLevel, m_iTitle, m_isLookon, szIP,m_iTotalCoin,m_iTotalRmb);
		return zjhmsg;
	}
};

class SUBCMD_S_Table extends IJsonExport { // 同步房间玩家信息
	int m_dwTableID;// 房间ID
	int m_lCellScore;
	int m_bTableStarted;// 只要开始玩
	int m_byRound;//
	int m_byMaxRound;//
	int m_bGameStarted;// 游戏开始
	int m_wCurrentUser;// 观众数量
	int m_curRoomMultiple;

	SSeatInfo m_seatInfo[] = new SSeatInfo[5];
	{
		for(int i=0;i<5;i++)
		{
			m_seatInfo[i] = new SSeatInfo();
		}
		m_dwTableID = 0;
		m_lCellScore = 1;
		m_bTableStarted = 1;// 只要开始玩
		m_byRound = 1;//
		m_byMaxRound = 8;//
		m_bGameStarted = 0;// 游戏开始
		m_wCurrentUser = 0;// 观众数量		
	}
	String getJsonData() {

		String zjhmsg = String.format("table|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s|%s|%s|%s", m_dwTableID, m_bTableStarted,
				m_byRound, m_byMaxRound, m_bGameStarted, m_lCellScore, m_wCurrentUser,m_curRoomMultiple, m_seatInfo[0].toString(),
				m_seatInfo[1].toString(), m_seatInfo[2].toString(), m_seatInfo[3].toString(), m_seatInfo[4].toString());
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_Lookon extends IJsonExport {// 同步房间玩家信息

	int m_cntLookon;// 观众
	SSeatInfo m_seatInfo[] = new SSeatInfo[5];

	String getJsonData() {
		String zjhmsg = String.format("guests|%d|%s|%s|%s|%s|%s", m_cntLookon, m_seatInfo[0].toString(),
				m_seatInfo[1].toString(), m_seatInfo[2].toString(), m_seatInfo[3].toString(), m_seatInfo[4].toString(),
				m_seatInfo[5].toString());
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_STAGE extends IJsonExport { // 同步房间玩家信息
	String szStage;

	int m_byZhuang;// 当前庄位置
	int m_wZhuangPower;// 当前庄的倍率
	int needDealTime;
	int m_bTableCardArray[] = new int[15]; // 桌面扑克
	int m_vecCardType[] = new int[5];
	int m_vecRoundScore[] = new int[5];

	String getJsonData() {

		String strCardType = Arrays.toString(m_vecCardType);
		strCardType = strCardType.substring(1, strCardType.length() - 1);

		String strRoundScore = Arrays.toString(m_vecRoundScore);
		strRoundScore = strRoundScore.substring(1, strRoundScore.length() - 1);

		String strTableCard = Arrays.toString(m_bTableCardArray);
		strTableCard = strTableCard.substring(1, strTableCard.length() - 1);

		String zjhmsg = String.format("stage|%s|%d|%d|%d|%s|%s|%s", szStage, m_byZhuang, m_wZhuangPower, needDealTime,
				strTableCard, strCardType, strRoundScore);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

class SUBCMD_S_REPORT extends IJsonExport {
	int cbReason;
	int whoDismiss;
	int vecMaxWinScore[] = new int[5];
	int vecWinScore[] = new int[5];
	int vecLoseScore[] = new int[5];
	double vecResultScore[] = new double[5];

	String getJsonData() {

		String strMaxWinScore = Arrays.toString(vecMaxWinScore);
		strMaxWinScore = strMaxWinScore.substring(1, strMaxWinScore.length() - 1);

		String strWinScore = Arrays.toString(vecWinScore);
		strWinScore = strWinScore.substring(1, strWinScore.length() - 1);

		String strLoseScore = Arrays.toString(vecLoseScore);
		strLoseScore = strLoseScore.substring(1, strLoseScore.length() - 1);

		String strResultScore = Arrays.toString(vecResultScore);
		strResultScore = strResultScore.substring(1, strResultScore.length() - 1);

		String zjhmsg = String.format("report|%d|%d|%s|%s|%s|%s", cbReason, whoDismiss, strMaxWinScore, strWinScore,
				strLoseScore, strResultScore);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};

// 游戏结束
class SUBCMD_S_JieSuan extends IJsonExport {
	int m_winnerSeat;
	int lTax; // 游戏税收
	double nGameGold[] = new double[5]; // 游戏得分
	double nUserScore[] = new double[5]; // 玩家得分
	double lShuiShou[] = new double[5];
	double lUserCoin[] = new double[5];
	String getJsonData() {
		String strGameGold = Arrays.toString(nGameGold);
		strGameGold = strGameGold.substring(1, strGameGold.length() - 1);

		String strUserScore = Arrays.toString(nUserScore);
		strUserScore = strUserScore.substring(1, strUserScore.length() - 1);
		String userCoin = sprintf_DOUBLE(lUserCoin,5);
		String userShui = sprintf_DOUBLE(lShuiShou,5);

		String zjhmsg = String.format("jiesuan|%d|%d|%s|%s|%s|%s", m_winnerSeat, lTax, strGameGold, strUserScore,userShui,userCoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();
	}
};
class SUBCMD_S_CanJoin extends IJsonExport {
	int lUid; // 当前玩家
	int wChairID; // 玩家座位号
	int canJoin; 

	public String getJsonData() {
		String zjhmsg = String.format("canjoin|%d|%d|%d", lUid, wChairID, canJoin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", zjhmsg);

		return json.toString();				
	}
};



//文字聊天
class SUBCMD_S_Text extends IJsonExport {
	int m_lUid;// 哪个玩家ID获得
	int m_wUserChairID;// 玩家座位号
	String szContent;

	String getJsonData() {
		String fjsszmsg = String.format("text|%d|%d|%s", m_lUid, m_wUserChairID, szContent);

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", fjsszmsg);
		return json.toString();
	}
};

class SUBCMD_S_VoiceMsg extends IJsonExport{
	int m_lUid;
	int m_wUserChairID;
	int m_maxClip;
	int m_currClip;
	float seconds;
	String data;
	
	String getJsonData() {

		String mjmsg = String.format("voicemsg|%d|%d|%f|%s|%d|%d", m_lUid, m_wUserChairID, seconds, data,m_maxClip,m_currClip);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);

		return json.toString();
	}
};

class SUBCMD_S_ExprMsg extends IJsonExport{
	int m_uid1;
	int m_uid2;
	int m_index;
	String getJsonData() {

		String mjmsg = String.format("expr|%d|%d|%d", m_uid1, m_uid2,m_index);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);

		return json.toString();
	}
};

class SUBCMD_S_InBack extends IJsonExport{
	int byActionUser;
	String getJsonData(){
		String mjmsg = String.format("inBack|%d", byActionUser);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);
		return json.toString();
	}
}
class SUBCMD_S_InFore extends IJsonExport{
	int byActionUser;
	String getJsonData(){
		String mjmsg = String.format("inFore|%d", byActionUser);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);
		return json.toString();
	}
}
class SUBCMD_S_OnLine extends IJsonExport{
	int uid;
	int seat;
	String getJsonData(){
		String mjmsg = String.format("online|%d|%d", uid,seat);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);
		return json.toString();
	}
}

class SUBCMD_S_GameIap extends IJsonExport{
	int uid;
	int seat;
	double coin;
	String getJsonData(){
		String mjmsg = String.format("gameiap|%d|%d|%g", uid,seat,coin);
		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", mjmsg);
		return json.toString();
	}
}
class SUBCMD_S_QuickMatchFinish extends IJsonExport{
	String getJsonData() {

		JSONObject json = new JSONObject();
		json.put("command", "zjhmsg");
		json.put("zjhmsg", "QuickMatchFinish");

		return json.toString();
	}
};